Skip to content

fix(toolkit-lib): says "stack destroyed" even if it was missing to begin with - #2186

Open
MaxonT wants to merge 1 commit into
aws:mainfrom
MaxonT:contrib/22240-auto
Open

MaxonT wants to merge 1 commit into
aws:mainfrom
MaxonT:contrib/22240-auto

Conversation

@MaxonT

@MaxonT MaxonT commented Nov 27, 2026 •

Copy link
Copy Markdown

Hey, this touches the cdk destroy command so it no longer says it succeeded when there are no stacks to destroy; I only had the issue title, so please check the message wording.

Fixes aws/aws-cdk#22240

Thanks to peterwoodworth and rix0rrr for laying out the options on that issue. The "no such stack" warning for a name that matches nothing in the app already exists (#984); what is still missing is the case where the stack is in the app but was never deployed (or is already gone). There deployments.destroyStack() finds nothing in CloudFormation and returns without an ARN, and destroy still prints ✅ Stack: destroyed.

This changes only that message: when destroyStack returns no stackArn, the result line reads ✅ Stack: not deployed, nothing to destroy. It is still a success (rix0rrr's point that the end state is what the user asked for), so there is no error and no change to the exit code or to DestroyResult (stackExisted was already false there). I did not move the existence lookup before the confirmation prompt, which the issue also floats; that is a bigger behaviour change and I wanted to keep this one small.

The message is produced in Toolkit._destroy, so a destroy run as rollback cleanup from deploy gets the same wording for a missing stack.

How I checked: added a test in toolkit-lib/test/actions/destroy.test.ts for a mocked destroyStack with no ARN; it fails on the base commit and passes with the change. The default mock in that file now returns an ARN, so the existing "destroyed" assertions still describe a real deletion. npx jest test/actions/destroy.test.ts passes (26 tests). Not run: the full toolkit-lib or aws-cdk suites, eslint (the local eslint config did not load), and a real cdk destroy against AWS.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@rix0rrr rix0rrr changed the title fix(toolkit-lib): say a stack is not deployed instead of reporting it destroyed fix(toolkit-lib): says "stack destroyed" even if it was missing to begin with Nov 30, 2026

This branch is waiting to be deployed

1 inactive and 1 waiting deployments
integ-approval — ff369b7f Waiting Nov 27, 2026 by MaxonT via prepare #7813
automation — ff369b7f Deployed Nov 27, 2026 by MaxonT via Set AutoQueue on PR #2186 #4053
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cdk: Destroy reports success when there is nothing to destroy

2 participants